﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class CapnhatInfo : System.Web.UI.Page
{
    SqlConnection con;
    SqlCommand cmd;
    DataTable dt = new DataTable();
    private string Connect = ConfigurationManager.ConnectionStrings["ketnoi"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"].ToString() == "")
        {
            Response.Redirect("DangNhap.aspx");
        }
        else
        {
            lbluser.Text = "Chào " + Session["username"].ToString();
        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        con = new SqlConnection(Connect);
        try
        {
            con.Open();
            cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "	update Dang_Nhap set Email='" + txtEmail.Text + "',CMND='" + txtcmnd.Text + "',HoVaTen=N'" + txthovaten.Text + "',NgaySinh='" + txtngaysinh.Text + "',DienThoai='" + txtdienthoai.Text + "',DiaChi=N'" + txtdiachinhanhang.Text + "',Tinh_TP=N'" + DropDownList1.Text + "' where TenDangNhap='" + Session["username"].ToString() + "'";
            int i;
            i = cmd.ExecuteNonQuery();
            if (i > 0)
            {
                Response.Redirect("Xemthongtinuser.aspx");

            }
            else
            {
                lblErr.Text = "Cập nhật thất bại";
            }
        }
        catch
        {
            lblErr.Text = "Lỗi kết nối";
        }
          
    }
}
